package com.jiasongfan.util;

import com.jiasongfan.entity.TbUser;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyHandlerInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        TbUser user = (TbUser) request.getSession().getAttribute("user");
        if (user==null){
            response.sendRedirect("tologin");
            return false;
        }
        return true;
    }
}
